<?php require_once('../connections/con_gl.php'); ?>

<?php

session_start();

function Terbilang($x)

{

  $abil = array("", "satu", "dua", "tiga", "empat", "lima", "enam", "tujuh", "delapan", "sembilan", "sepuluh", "sebelas");

  if ($x < 12)

    return " " . $abil[$x];

  elseif ($x < 20)

    return Terbilang($x - 10) . "belas";

  elseif ($x < 100)

    return Terbilang($x / 10) . " puluh" . Terbilang($x % 10);

  elseif ($x < 200)

    return " seratus" . Terbilang($x - 100);

  elseif ($x < 1000)

    return Terbilang($x / 100) . " ratus" . Terbilang($x % 100);

  elseif ($x < 2000)

    return " seribu" . Terbilang($x - 1000);

  elseif ($x < 1000000)

    return Terbilang($x / 1000) . " ribu" . Terbilang($x % 1000);

  elseif ($x < 1000000000)

    return Terbilang($x / 1000000) . " juta" . Terbilang($x % 1000000);

}



function tanggal($xdate,$par) {

$_t = explode("/",$xdate);

$_t1 = $_t[0];

$_t2 = $_t[1];

$_t3 = $_t[2];

switch($_t2) {

	case("12"):

	$bln_eng = "Dec";

	break;     

	case("11"):

	$bln_eng = "Nov";

	break;

	case("10"):

	$bln_eng = "Okt";

	break;

	case("09"):

	$bln_eng = "Sep";

	break;

	case("08"):

	$bln_eng = "Aug";

	break;

	case("07"):

	$bln_eng = "Jul";

	break;

	case("06"):

	$bln_eng = "Jun";

	break;

	case("05"):

	$bln_eng = "May";

	break;

	case("04"):

	$bln_eng = "Apr";

	break;

	case("03"):

	$bln_eng = "Mar";

	break;

	case("02"):

	$bln_eng = "Feb";

	break;

	default:

	$bln_eng = "Jan";

	break;

}

$gentgl = $_t3."&nbsp;".$bln_eng."&nbsp;".$_t1;

if($par=='tampilkan') {

 echo $gentgl;

}

} 

mysql_select_db($database_con_gl, $con_gl);

if($_REQUEST['tipecust']=='R'){
//Ini untuk query cust. retail
$query_data = "select a.id, a.tgl, a.noref, a.info, a.driver, b.nopolisi, b.tahun, b.warnautama, b.norangka, b.nomesin, c.tipekendaraan, e.merk, d.kontak, d.checkin, d.waktucheckin, d.checkout, d.waktucheckout from gl_kkeluar a, gl_masterkendaraan b, gl_tipekendaraan c, gl_retailtrans d, gl_merkkendaraan e where a.id='$_GET[id]' AND a.kendaraan = b.nopolisi AND b.tipekendaraan = c.id AND b.merk = e.id AND a.noref = d.no_ref";
$data = mysql_query($query_data, $con_gl) or die(mysql_error());
$row_data = mysql_fetch_assoc($data);
}else{
//Ini untuk query cust. corporate
$query_data = "select a.id, a.tgl, a.noref, a.info, a.driver, b.nopolisi, b.tahun, b.warnautama, b.norangka, b.nomesin, c.tipekendaraan, e.merk, d.no, d.mulai, d.sampai from gl_kkeluar a, gl_masterkendaraan b, gl_tipekendaraan c, gl_kontrak d, gl_merkkendaraan e where a.id='$_GET[id]' AND a.kendaraan = b.nopolisi AND b.tipekendaraan = c.id AND b.merk = e.id AND a.noref = d.no";
$data = mysql_query($query_data, $con_gl) or die(mysql_error());
$row_data = mysql_fetch_assoc($data);
list($row_data['kontak']) = mysql_fetch_row(mysql_query("select kontak from gl_kontrak where no = '$row_data[noref]' "));
}

// --- get customer
$cust = mysql_query("select * from gl_kontak where id='$row_data[kontak]'", $con_gl) or die(mysql_error());
$row_cust = mysql_fetch_assoc($cust);
// --- get driver
$driv = mysql_query("select * from gl_kontak where id='$row_data[driver]'", $con_gl) or die(mysql_error());
$row_driv = mysql_fetch_assoc($driv);
//---
$startTimeStamp = strtotime($row_data['checkin']);

$endTimeStamp = strtotime($row_data['checkout']);



$timeDiff = abs($endTimeStamp - $startTimeStamp);



$numberDays = $timeDiff/86400;  // 86400 seconds in one day



// and you might want to convert to integer

$numberDays = intval($numberDays);

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Delivery Order #<?php echo $_GET[referensi];?></title>

<style>

body {

padding:0;

margin:0;

font-family:Verdana, Arial, Helvetica, sans-serif;

font-size:11px;

line-height:14px;

}

h2 {

padding:0;

margin:0;

font-family:Verdana, Arial, Helvetica, sans-serif;

font-size:18px;

font-style:italic

}

#edisi tr td {

font-size:8px;

}

</style>

</head>



<body onload="javascript: window.print();">

<table width="729" border="1" align="center" cellpadding="6" cellspacing="0" style="border:solid 1px #000000;">

  <tr>
    <td width="715" colspan="5" align="center" valign="top"><h5>PT. TRANSPORTASI LINTAS INDONESIA </h5>  
    <h5>BERITA ACARA SERAH TERIMA KENDARAAN KENDARAAN(BAST)</h5></td>
  </tr>
  <tr>
    <td colspan="5" align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="2">
      <tr>
        <td width="19%">Kepada YTH</td>
        <td width="1%" align="center">&nbsp;</td>
        <td colspan="4">&nbsp;</td>
      </tr>
      <tr>
        <td>Nama</td>
        <td align="center">:</td>
        <td colspan="4" valign="top"><?php echo $row_cust['nama'];?></td>
      </tr>
      <tr>
        <td>Alamat</td>
        <td align="center">:</td>
        <td colspan="4" valign="top"><?php echo $row_cust['alamat'];?></td>
      </tr>
      <tr>
        <td>No. Telp</td>
        <td align="center">:</td>
        <td colspan="4" valign="top"><?php echo $row_cust['tlp'];?></td>
      </tr>
      <tr>
        <td>Email</td>
        <td align="center">:</td>
        <td colspan="4" valign="top"><?php echo $row_cust['email'];?></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td align="center">&nbsp;</td>
        <td colspan="4">&nbsp;</td>
      </tr>
      <tr>
        <td colspan="6"><strong>Harap diterima 1( Satu ) Unit Kendaraan dengan spesifikasi sbb; </strong></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td align="center">&nbsp;</td>
        <td colspan="4">&nbsp;</td>
      </tr>
      
      <tr>
        <td>Tipe</td>
        <td align="center">:</td>
        <td width="25%" valign="top"><?php echo $row_data['tipekendaraan'];?></td>
        <td width="17%">No. Polisi</td>
        <td width="1%" valign="top">:</td>
        <td width="37%" valign="top"><?php echo $row_data['nopolisi'];?></td>
      </tr>
      <tr>
        <td>Merk</td>
        <td align="center">:</td>
        <td valign="top"><?php echo $row_data['merk'];?></td>
        <td>No. Rangka</td>
        <td valign="top">:</td>
        <td valign="top"><?php echo $row_data['norangka'];?></td>
      </tr>
      <tr>
        <td>Tahun</td>
        <td align="center">:</td>
        <td valign="top"><?php echo $row_data['tahun'];?></td>
        <td>No. Mesin</td>
        <td valign="top">:</td>
        <td valign="top"><?php echo $row_data['nomesin'];?></td>
      </tr>
      <tr>
        <td>Warna</td>
        <td align="center">:</td>
        <td><?php echo $row_data['warnautama'];?></td>
        <td>KM Awal </td>
        <td>:</td>
        <td><input name="kmawal" type="text" id="kmawal" size="10" maxlength="10" /></td>
      </tr>
      
      <tr>
        <td>&nbsp;</td>
        <td align="center">&nbsp;</td>
        <td valign="top">&nbsp;</td>
        <td valign="top">FUEL Keluar </td>
        <td valign="top">:</td>
        <td valign="top"><input name="ada" type="checkbox" id="ada" value="" />
          E 
          <input name="ada2" type="checkbox" id="ada2" value="" />
          1/8 
          <input name="ada3" type="checkbox" id="ada3" value="" />
          1/4 
          <input name="ada4" type="checkbox" id="ada4" value="" />
          1/2
          <input name="ada5" type="checkbox" id="ada5" value="" />
          3/4 
          <input name="ada6" type="checkbox" id="ada6" value="" />
          F</td>
      </tr>
      
      <tr>
        <td colspan="6"><strong>Keterangan</strong></td>
      </tr>
      <tr>
        <td>No. Kontrak </td>
        <td align="center">:</td>
        <td colspan="4"><?php echo $row_data['no'];?></td>
      </tr>
      <tr>
        <td>Periode Kontrak </td>
        <td align="center">:</td>
        <td colspan="4"><?php tanggal($row_data['mulai'],"tampilkan");?> - <?php tanggal($row_data['sampai'],"tampilkan");?></td>
      </tr>
      <tr>
        <td>Tanggal Pengiriman </td>
        <td align="center">:</td>
        <td colspan="4"><?php tanggal(date("Y/m/d"),"tampilkan");?></td>
      </tr>
      <tr>
        <td>Tanggal Ckeck OUT </td>
        <td align="center">:</td>
        <td colspan="4"><?php tanggal(date("Y/m/d"),"tampilkan");?></td>
      </tr>
      <tr>
        <td>Jam Check OUT </td>
        <td align="center">:</td>
        <td colspan="4" valign="top"><?php echo date("H:i");?></td>
      </tr>
      
      <tr>
        <td>&nbsp;</td>
        <td align="center">&nbsp;</td>
        <td colspan="4">&nbsp;</td>
      </tr>
      
    </table></td>
  </tr>
  <tr>
    <td colspan="5" align="left" valign="top"><table width="100%" border="1" cellspacing="0" cellpadding="2">
      <tr>
        <td width="33%" align="center"><strong>Penerima / Penyewa</strong></td>
        <td width="33%" align="center"><strong>Supir</strong></td>
        <td align="center"><strong>Hormat Kami</strong></td>
      </tr>
      <tr align="center" valign="bottom">
        <td height="65"><?php echo $row_cust['nama'];?></td>
        <td height="65"><p>&nbsp;</p>
          <p>&nbsp;</p>
          <p>&nbsp;</p>
          <p><?php echo $row_driv['nama'];?></p></td>
        <td height="65"><p>&nbsp;</p>
          <p>&nbsp;</p>
          <?php echo $_SESSION[nama];?></td>
      </tr>
    </table></td>
  </tr>
  <!--<tr>

    <td align="center" valign="top">&nbsp;</td>

    <td align="center" valign="top">&nbsp;</td>

    <td align="center" valign="top">&nbsp;</td>

    <td align="center" valign="top">&nbsp;</td>

    <td align="center" valign="top">&nbsp;</td>

  </tr>-->

</table>

</body>

</html>

<?php

mysql_free_result($getppn);



mysql_free_result($kontak);



mysql_free_result($brg);



mysql_free_result($gettgl);



mysql_free_result($company);



mysql_free_result($tr1);

?>